// import QtQuick 1.0 // to target S60 5th Edition or Maemo 5
import QtQuick 1.1

Rectangle {
    id: rect
    width: 600
    height: 600
    Grid {
        Repeater {
            id: rep
            model: 16
            Rectangle {
               id: sqr
               property alias text: textInput.text
               width: rect.width / 4
               height: width
               border.width: 1
               TextInput {
                   id: textInput
                   text: ""
                   anchors.centerIn: parent
                   font.pixelSize: 56
                   validator: IntValidator {
                       bottom: 1
                       top: 4
                   }
                   onTextChanged: {
                       var i, j;
                       for (i = 0; i < 4; ++i) {
                           for (j = 0; j < 4; ++j) {
                               if (rep.itemAt(i*4 + j).text === "")
                                   return;
                               
                           }
                       }
                   }
               }
               MouseArea {
                   anchors.fill: parent
                   onClicked: {
                       textInput.focus = true
                       textInput.text = ""
                   }
               }
            }
        }
    }
}
